//
//  WindowMessageView.m
//  SlashEM
//
//  Created by dirk on 1/19/10.
//  Copyright 2010 Dirk Zimmermann. All rights reserved.
//

//  This file is part of Slash'EM.
//
//  Slash'EM is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, version 2 of the License only.
//
//  Slash'EM is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with Slash'EM.  If not, see <http://www.gnu.org/licenses/>.

#import "WindowMessageView.h"
#import "MainViewController.h"

@implementation WindowMessageView

@synthesize nhWindow;

- (BOOL)becomeFirstResponder {
	if (nhWindow) {
		CGPoint contentOffset = self.contentOffset;
		if (contentOffset.y > 0) {
			[self setContentOffset:CGPointMake(0.0f, 0.0f) animated:YES];
		} else {
			CGSize contentSize = self.contentSize;
			float textHeight = contentSize.height;
			float height = self.bounds.size.height;
			float scrollToY = textHeight-height;
			scrollToY = scrollToY < 0.0f ? 0.0f : scrollToY;
			[self setContentOffset:CGPointMake(0.0f, scrollToY) animated:YES];
		}
	}
	return NO;
}

@end
